From: kaf24@localhost.localdomain Date: Fri, 27 Oct 2006 17:10:37 +0000 (+0100) Subject: [XEN] perf counters: Fix NULL-pointer check. Should happen later. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15567^2~192 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=98781cd038ae920c06f7ba8ee0a2986b104e5a4d;p=xen.git [XEN] perf counters: Fix NULL-pointer check. Should happen later. Signed-of-by: Kouya Shimura --- diff --git a/xen/common/perfc.c b/xen/common/perfc.c index 1903ef2f4e..471bd3cd2b 100644 --- a/xen/common/perfc.c +++ b/xen/common/perfc.c @@ -143,9 +143,6 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc, unsigned int v = 0; atomic_t *counters = (atomic_t *)&perfcounters; - if ( guest_handle_is_null(desc) ) - return 0; - /* We only copy the name and array-size information once. */ if ( !perfc_init ) { @@ -175,7 +172,11 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc, perfc_vals = xmalloc_array(xen_sysctl_perfc_val_t, perfc_nbr_vals); perfc_init = 1; } - if (perfc_vals == NULL) + + if ( guest_handle_is_null(desc) ) + return 0; + + if ( perfc_vals == NULL ) return -ENOMEM; /* Architecture may fill counters from hardware. */ @@ -207,9 +208,9 @@ static int perfc_copy_info(XEN_GUEST_HANDLE(xen_sysctl_perfc_desc_t) desc, } BUG_ON(v != perfc_nbr_vals); - if (copy_to_guest(desc, (xen_sysctl_perfc_desc_t *)perfc_d, NR_PERFCTRS)) + if ( copy_to_guest(desc, (xen_sysctl_perfc_desc_t *)perfc_d, NR_PERFCTRS) ) return -EFAULT; - if (copy_to_guest(val, perfc_vals, perfc_nbr_vals)) + if ( copy_to_guest(val, perfc_vals, perfc_nbr_vals) ) return -EFAULT; return 0; }